package JAVA300.第十二章网络编程;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

/**
 *练习网络爬虫
 * 1.获取URL
 * 2.下载资源
 * 3.分析处理等
 */

public class Web03_SpiderTest01 {
    public static void main(String[] args) {

        try {
            //获取URL
            URL url = new URL("https://www.dianping.com");
            //下载资源--IO操作

            InputStream inputStream = url.openStream();//字节流
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
            String msg = null;
            while ( null != (msg= reader.readLine())){
                System.out.println(msg);
            }
            reader.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
